package com.example.studentcompetitionplatform.controller;

import com.example.studentcompetitionplatform.entity.Competitions;
import com.example.studentcompetitionplatform.entity.Registrations;
import com.example.studentcompetitionplatform.mapper.JingSaiBaoMingMapper;
import com.example.studentcompetitionplatform.service.IJingSaiBaoMingService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/baoming")
public class JingSaiBaoMingController {
    @Resource
    private IJingSaiBaoMingService jingSaiBaoMingService;
    //报名
    @PostMapping("/singup")
    public Integer register(@RequestBody Registrations registrations){
        jingSaiBaoMingService.insertR(registrations);
        return 1;
    }
    //分页数据查询
    @GetMapping("/page")
    public Map<String, Object> findPage(@RequestParam(value = "pageNum") Integer pageNum,
                                        @RequestParam(value = "pageSize") Integer pageSize,
                                        @RequestParam(value = "competitionId",required = false) Integer competitionId
    ) {
        return jingSaiBaoMingService.page(pageNum,pageSize,competitionId);
    }
}
